package com.baizhi.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * 1.实现过滤器接口  Filter  javax.servlet.Filter
 * 2.实现接口中doFilter方法
 */
public class LoginFilter implements Filter {
    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
       /* *  这里自己写的强制登陆过滤器先注释掉  因为shiro框架中的配置类中也可以配置过滤规则
       //转换形参的类型
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;
        //获取登陆标识
        HttpSession session = request.getSession();
        Object admin = session.getAttribute("login");
        //判断是否放行
        if(admin==null){
            //重定向
            response.sendRedirect(request.getContextPath()+"/login.jsp");
        }else {
            //放行请求
            chain.doFilter(request,response);
        }*/
    }
}
